<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@page import="org.jeecgframework.web.util.StaticValue" %>
<%@include file="/context/mytags.jsp" %>
<t:base type="jquery,easyui,tools,DatePicker"></t:base>
<div class="easyui-layout" fit="true">
    <div region="center" style="padding:1px;">
        <t:datagrid name="cbsServiceList" checkbox="true" fitColumns="false" title="CSA服务单管理"
                    actionUrl="cbsServiceController.do?datagrid" idField="id" queryMode="group" sortOrder="asc" sortName="status,createDate" onLoadSuccess="changeColor" pageList="[20,100,500]">
            <t:dgCol title="id"  field="id"  hidden="true"  queryMode="single"  width="120"></t:dgCol>
            <t:dgCol title="服务单号" field="code" queryMode="single" width="125" query="true"></t:dgCol>
            <t:dgCol title="创单时间" field="createDate" formatter="yyyy-MM-dd hh:mm" queryMode="group" width="105" query="true"></t:dgCol>
            <t:dgCol title="当前责任人" field="personliable" queryMode="single" width="80" query="true"></t:dgCol>
            <t:dgCol title="服务单状态" field="status" width="75" sortable="false" dictionary="<%=StaticValue.Source_State %>"></t:dgCol>
            <t:dgCol title="影院名称" field="names" queryMode="single" width="180" query="true"></t:dgCol>
            <t:dgCol title="设备SN" field="sn" queryMode="single" width="120" query="true"></t:dgCol>
            <t:dgCol title="SR号" field="SR" queryMode="single" width="70" query="true"></t:dgCol>
            <t:dgCol title="SO号" field="SO" queryMode="single" width="80" query="true"></t:dgCol>
            <t:dgCol title="报价单号" field="offerno" queryMode="single" width="110" query="true"></t:dgCol>
            <t:dgCol title="影院地址" field="address" queryMode="single" width="200"></t:dgCol>
            <t:dgCol title="院线" field="intheaterName" queryMode="single" width="60" query="true"></t:dgCol>
            <t:dgCol title="联系人姓名" field="contactsName" queryMode="single" width="80"></t:dgCol>
            <t:dgCol title="省市" field="province" width="100" sortable="false" hidden="true" queryMode="single" query="true"/>
            <t:dgCol title="联系人手机" field="phone" queryMode="single" width="100" query="true"></t:dgCol>
            <t:dgCol title="服务单类型" field="serviceType2" queryMode="single" width="85" query="true"></t:dgCol>
            <t:dgCol title="级别" field="level" queryMode="single" width="40"></t:dgCol>
            <t:dgCol title="服务单状态"  field="status1" hidden="true"  query="true"></t:dgCol>
            <t:dgCol title="服务单状态"  field="status2" hidden="true"  query="true"></t:dgCol>
<t:dgCol title="服务商" field="serviceProvider" replace="华夏影联_华夏影联,中仪_中仪,天影_天影,时代_时代,中巴服务_中巴服务,CGV服务_CGV服务" queryMode="single" width="80" query="true"></t:dgCol>
            <t:dgCol title="服务商处理进度" field="speedstatus" queryMode="single" width="110"
                     dictionary="<%=StaticValue.Third_Party_Processing_Progress %>"></t:dgCol>
            <t:dgCol title="服务商处理进度"  field="speedstatus1" hidden="true"  query="true"></t:dgCol>
            <t:dgCol title="服务商处理进度"  field="speedstatus2" hidden="true"  query="true"></t:dgCol>
            <t:dgCol title="备件审批" field="approStatus"  replace="未申请备件_0,未审批_1,通过_2,不通过_3" queryMode="single" width="70" query="true"></t:dgCol>
            <t:dgCol title="关单时间" field="closeTime" formatter="yyyy-MM-dd hh:mm" queryMode="group" width="105" query="true"></t:dgCol>
  <%--          <t:dgCol title="最后更新时间" field="updatedate" formatter="yyyy-MM-dd hh:mm"  queryMode="group" width="105"></t:dgCol>--%>
            <t:dgCol title="来源" field="sourceType" width="60" sortable="false" dictionary="<%=StaticValue.Source_Type %>"></t:dgCol>
            <t:dgToolBar title="新建服务单" operationCode="addservicecsa" icon="icon-add" funname="addCreateTab"></t:dgToolBar>
            <t:dgToolBar title="编辑" operationCode="editservicecsa" icon="icon-edit" funname="addNewTab"></t:dgToolBar>
            <t:dgToolBar title="查看" operationCode="searchservicecsa" icon="icon-search" funname="detail"></t:dgToolBar>
            <t:dgToolBar title="导出" operationCode="putoutservicecsa" icon="icon-putout" funname="exportIp"></t:dgToolBar>
        </t:datagrid>
    </div>
</div>
<script src="webpage/com/zybk/cbsservice/cbsServiceList.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        //给时间控件加上样式
        $("#cbsServiceListtb").find("input[name='createDate_begin']").attr("class", "Wdate").attr("style", "height:20px;width:90px;").click(function () {
            WdatePicker({dateFmt: 'yyyy-MM-dd'});
        });
        $("#cbsServiceListtb").find("input[name='createDate_end']").attr("class", "Wdate").attr("style", "height:20px;width:90px;").click(function () {
            WdatePicker({dateFmt: 'yyyy-MM-dd'});
        });
        $("#cbsServiceListtb").find("input[name='closeTime_begin']").attr("class", "Wdate").attr("style", "height:20px;width:90px;").click(function () {
            WdatePicker({dateFmt: 'yyyy-MM-dd'});
        });
        $("#cbsServiceListtb").find("input[name='closeTime_end']").attr("class", "Wdate").attr("style", "height:20px;width:90px;").click(function () {
            WdatePicker({dateFmt: 'yyyy-MM-dd'});
        });
        territoryLink("cbsServiceList","province",1);
        territoryLinks('cbsServiceList', 'serviceType2', 1);
    });
    $(function () {
        $("div[name='searchColums'] span:nth-child(13)").hide();
        var status=$("#status").val();
        $("[name='status2']").combobox({
            //url:'cbsServiceController.do?getComboboxData',
            data:[{
                "id":1,
                "text":"待处理"
            },{
                "id":2,
                "text":"已受理"
            },{
                "id":3,
                "text":"处理中",
            },{
                "id":4,
                "text":"已完成"
            },{
                "id":5,
                "text":"已取消"
            }],
            valueField: 'id',
            textField: 'text',
            editable:false,
            multiple:true,
            onSelect: function (row) { //选中一个选项时调用
                //获取选中的值的values
                $("[name='status1']").val($(this).combobox('getValues'));
            },
            onUnselect: function (row) {//不选中一个选项时调用
                //获取选中的值的values
                $("[name='status1']").val($(this).combobox('getValues'));
            }
        });
        //服务商处理进度
        $("div[name='searchColums'] span:nth-child(16)").hide();
        $("[name='speedstatus2']").combobox({
            data:[{
                "id":0,
                "text":"HD待分派"
            },{
                "id":1,
                "text":"第三方已拒绝"
            },{
                "id":2,
                "text":"已分派第三方",
            },{
                "id":3,
                "text":"第三方已分配"
            },{
                "id":4,
                "text":"区域工程师已分配"
            },{
                "id":5,
                "text":"工程师已接受"
            },{
                "id":6,
                "text":"工程师实施中"
            },{
                "id":7,
                "text":"服务已完成"
            }],
            valueField: 'id',
            textField: 'text',
            editable:false,
            multiple:true,
            onSelect: function (row) { //选中一个选项时调用
                //获取选中的值的values
                $("[name='speedstatus1']").val($(this).combobox('getValues'));
            },
            onUnselect: function (row) {//不选中一个选项时调用
                //获取选中的值的values
                $("[name='speedstatus1']").val($(this).combobox('getValues'));
            }
        });
    });

    function searchReset(){
        addOneTab("CSA服务单管理","cbsServiceController.do?cbsServiceForCSA","");
    }

    //导入
    function ImportXls() {
        openuploadwin('Excel导入', 'cbsServiceController.do?upload', "cbsServiceList");
    }

    //导出
    function ExportXls() {
        JeecgExcelExport("cbsServiceController.do?exportXls", "cbsServiceList");
    }

    //模板下载
    function ExportXlsByT() {
        JeecgExcelExport("cbsServiceController.do?exportXlsByT", "cbsServiceList");
    }

    function addCreateTab() {
        addOneTab('新建服务单', 'cbsServiceController.do?goAdd', '');
    }

    function addNewTab() {
        var datas = $("#cbsServiceList").datagrid("getSelections");
        if (datas.length != 1) {
            tip("请选择一条服务单");
            return;
        }
        var id = datas[0].id;
        var code = datas[0].code;
        var sn = datas[0].sn;
        addOneTab("CSA编辑服务单"+code, "cbsServiceController.do?goUpdateForCSA&id=" + id + "&sn=" + sn+"&code="+code, "");
    }

    function detail() {
        var datas = $("#cbsServiceList").datagrid("getSelections");
        if (datas.length != 1) {
            tip("请选择一条服务单");
            return;
        }
        var id = datas[0].id;
        var code = datas[0].code;
        var sn = datas[0].sn;
        addOneTab("服务单详情"+code, "cbsServiceController.do?detail&id=" + id + "&sn=" + sn+"&code="+code, "");
    }


    function exportIp() {
        var currPageRows = $("#cbsServiceList").datagrid("getRows");
        var idsData = [];
        $(currPageRows).each(function (i, rowData) {
            idsData.push(rowData.id);
        });
        if (idsData.length > 0) {
            myDownload("cbsServiceController.do?exportInspectionPlan", "planIds=" + idsData.join(","));
        } else {
            tip("当前页面没有数据可以导出");
        }
    }
    
            /*待处理的文字为红色*/
    function changeColor() {
        var trs = $("#cbsServiceList").prev().find('div.datagrid-body').find('tr');
        for (var i = 0; i < trs.length; i++) {

            for (var j = 0; j < 2; j++) {
                 if (trs[i].cells[j].firstChild.innerHTML =='待处理' ){
                    trs[i].cells[j].style.cssText = 'color:red';
                }
            }
        }
    }

</script>